package model

import (
	"fmt"
	"github.com/gomodule/redigo/redis"
)

// SaveImgCode 将图片的uuid和str对应起来存储到redis中
func SaveImgCode(uuid, code string) error {
	// 1. 连接数据库
	conn, err := redis.Dial("tcp", "127.0.0.1:6379")
	if err != nil {
		fmt.Println("redis Dial err: ", err)
		return err
	}
	defer conn.Close()

	// 2. 操作数据库
	_, err = conn.Do("setex", uuid, 60*5, code)

	return err
}
